package com.icemelon.catdog.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.icemelon.catdog.dao.NoticeMapper;
import com.icemelon.catdog.pojo.Affair;
import com.icemelon.catdog.pojo.Notice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

@Service
public class UserNoticeServiceImpl implements UserNoticeService {
    @Autowired
    private NoticeMapper noticeMapper;
    @Override
    public void uploadNotice(Notice notice) {
        noticeMapper.insert(notice);

    }

    @Override
    public List<Notice> getNotice(Integer[] ids) {
        List<Integer> list = Arrays.asList(ids);
        return noticeMapper.selectBatchIds(list);
    }

    @Override
    public void deleteNotice(Integer[] ids) {
        List<Integer> list= Arrays.asList(ids);
        noticeMapper.deleteBatchIds(list);
    }

    @Override
    public List<Notice> getAllNotice(Integer id) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq(id!=null && id>=0,"id",id);
        List<Notice> noticeList = noticeMapper.selectList(queryWrapper);
        return noticeList;
    }
}
